<template>
  <div>
    <div id="doughnut" style="width:400px;height:200px;"></div>
  </div>
</template>
<script>
import echarts from "echarts";
export default {
  mounted() {
    var doughnut = echarts.init(document.getElementById("doughnut"));
    var option = {
      tooltip: {
        trigger: "item",
        formatter: "{a} <br/>{b}: {c} ({d}%)"
      },
      legend: {
        orient: "vertical",
        right: 20,
        data: ["抄表", "换表", "报装", "热线", "校表","其他"]
      },
      series: [
        {
          name: "访问来源",
          type: "pie",
          radius: ["50%", "70%"],
          center: ["30%", "45%"],
          avoidLabelOverlap: false,
          label: {
            normal: {
              show: false,
              position: "center"
            },
            emphasis: {
              show: true,
              textStyle: {
                fontSize: "30",
                fontWeight: "bold"
              }
            }
          },
          labelLine: {
            normal: {
              show: false
            }
          },
          data: [
            { value: 335, name: "抄表" },
            { value: 310, name: "换表" },
            { value: 234, name: "报装" },
            { value: 135, name: "热线" },
            { value: 1000, name: "校表" },
            { value: 548, name: "其他" }
          ]
        }
      ]
    };
     doughnut.setOption(option, true);
  }
};
</script>